home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / bbs / twall62s.zip / thewall.mex < prev    next >
Text File  |  1996-07-27  |  6KB  |  162 lines

  1. /////////////////////////////////////////////////////////////////////
  2. //
  3. // thewall.mex
  4. //
  5. // version 6.1 beta 1
  6. //
  7. // desc: Maximus graffiti wall
  8. //
  9. // Copyright, 1996, Robert Thomson
  10. // (3:622/447.1) <ourmth@net-unix.newcastle.edu.au>
  11. //
  12. /////////////////////////////////////////////////////////////////////
  13.  
  14. // NOTE: New addition - Add to docs - Config file to use can be specified as
  15. //                                    a parameter.
  16.  
  17. #include <max.mh>           // needed for all MEX programs
  18. #include <altcol.mh>        // alternate colours for .bbs writing w/o probs
  19. string: current_colour;     // Global variable - needed for colours.mh
  20. #include <colours.mh>       // all my colour handling stuff, + more..
  21. #include <config.mh>        // my config file interpretation stuff
  22. #include <thewall.mh>       // my general tid-bit function file
  23.  
  24. void main(string: configfile)
  25. {
  26.  string: signature, tmpline, timedate, tmpstr;
  27.  struct _stamp: tdate;      // Make a time/date structure
  28.  int: fhandle, fhandle2, k, l, bl;
  29.  char: i,nonstop;
  30.  
  31.  if (configfile="") {
  32.                      if (fileexists("THEWALL.CFG")) configfile:="THEWALL.CFG";
  33.                         else { log("!Default THE WALL config file THEWALL.CFG doesn't exist");
  34.                                print("Default THE WALL config file THEWALL.CFG doesn't exist");
  35.                                pause();
  36.                                goto end; }
  37.                     }
  38.  else if (fileexists(configfile)=FALSE)
  39.                     {
  40.                      log("!THE WALL config file specified as a parameter doesn't exist");
  41.                      print("THE WALL config file specified as a parameter doesn't exist");
  42.                      pause();
  43.                      goto end;
  44.                     }
  45.  
  46.     ln.x[1]:=7;     ln.y[1]:=12;    // Define all the x,y positions
  47.     ln.x[2]:=8;     ln.y[2]:=12;    // for the different lines
  48.     ln.x[3]:=9;     ln.y[3]:=12;    //
  49.     ln.x[4]:=10;    ln.y[4]:=12;    // NOTE: make these definable in
  50.     ln.x[5]:=11;    ln.y[5]:=12;    // future versions
  51.  
  52.  
  53.  nonstop:=0;                        // for display_file - make nonstop disp
  54.  
  55. // loadconfig();                      // Load from thewall.cfg
  56.  loadconfig(configfile);                      // Load from thewall.cfg
  57.  
  58.  current_colour:=textcolour;        // Set current colour to default
  59.  
  60.  display_file(wallwritebbs, nonstop); // Grafitti Add Screen
  61.  print(textcolour);
  62.  
  63.  for (l := 1; l <= 5; l := l + 1)       //read lines of input from user
  64.  {
  65.   ln.text[l]:=getline(l,current_colour);
  66.   showline(l);                          // show line with changed col's
  67.   if (strlower(ln.text[1]) = "/q") goto end;    // abort if line 1 is /q
  68.   if (strlower(ln.text[l]) = "/q")
  69.             {
  70.              gotoxy(ln.x[l],ln.y[l]);       // blank the /q so it
  71.              print("  ");                   // looks normal
  72.              ln.text[l] := "";       // clearline
  73.              l:=6;                  // abort for()
  74.             }
  75.  }
  76.  
  77.  if (privok("<="+noaliaslevel))
  78.  {
  79.   if (userealname=FALSE and usr.alias<>"") signature:=usr.alias;
  80.     else signature:=usr.name;
  81.  
  82.   print(AVATAR_GOTO, (char)12, (char)24);
  83.   print("                              ");
  84.   print(AVATAR_GOTO, (char)12, (char)24);
  85.   print(signcolour+strpad(signature,30,' '));
  86.  }
  87.  else signature:=getsig(signature);               // get signature
  88.  
  89.  saveit:
  90.  print(AVATAR_GOTO, (char)16, (char)1, promptcolour+"Line # to edit, "+highlcolour+"S"+promptcolour+" to Save, "+highlcolour+"A"+promptcolour+" to abort? "+highlcolour+"<1-6, "+defaultcolour+"S"+highlcolour+"/a>");
  91.  i:=input_ch(CINPUT_ACCEPTABLE,"SA123456");
  92.  if (i = 'A') goto end;
  93.  if (i = 'S') goto savenow;
  94.  if (i = '1') { ln.text[1]:=getline(1,textcolour);
  95.                 update(1); goto saveit; }
  96.  if (i = '2') { ln.text[2]:=getline(2,ln.colour[1]);
  97.                 current_colour:=ln.colour[1];
  98.                 update(2); goto saveit; }
  99.  if (i = '3') { ln.text[3]:=getline(3,ln.colour[2]);
  100.                 current_colour:=ln.colour[2];
  101.                 update(3); goto saveit; }
  102.  if (i = '4') { ln.text[4]:=getline(4,ln.colour[3]);
  103.                 current_colour:=ln.colour[3];
  104.                 update(4); goto saveit; }
  105.  if (i = '5') { ln.text[5]:=getline(5,ln.colour[4]);
  106.                 current_colour:=ln.colour[4];
  107.                 update(5); goto saveit; }
  108.  if (privok(">"+noaliaslevel))
  109.    if (i = '6') { signature:=getsig(signature);
  110.                   goto saveit; }
  111.  
  112.  savenow:
  113.  remove(tmpfile); // remove tmpfile from last time
  114.  filecopy(bbsfile,tmpfile); // rename() didn't seem to work too well?!
  115.  
  116.  // Open WALLDISP.BBS for writing..
  117.  fhandle:=open(bbsfile, IOPEN_CREATE | IOPEN_WRITE);
  118.  if (fhandle=-1) log("!Walldisp.bbs had an error while opening");
  119.  
  120. ////// Detect Blank lines at bottom and "cut" them out //////
  121.  bl:=6;
  122.  for (l := 5; l>=2; dec(l))
  123.  {
  124.   if ((bl=(l+1)) AND (ln.text[l]="")) bl:=l;
  125.  }
  126.  
  127.  writeln(fhandle, textcolour + colstring(ln.text[1]));
  128.  for (l := 2; l<=5; l := l + 1)
  129.  {
  130.   if (l=bl) l:=6;
  131.   if (l <= 5) writeln(fhandle, colstring(ln.text[l]));
  132.  }
  133.  
  134.  writesig:;
  135.  timestamp(tdate); timedate:=stamp_string(tdate);
  136.  if (privok("<="+noaliaslevel))
  137.  {
  138.   if (userealname=FALSE and usr.alias<>"") signature:=usr.alias;
  139.     else signature:=usr.name;
  140.  }
  141.  if (showdate=TRUE) writeln(fhandle, writtenbycolour+"Written by: "+signcolour+colstring(signature)+writtenbycolour+" on the "+timedatecol+timedate);
  142.  if (showdate=FALSE) writeln(fhandle, writtenbycolour+"Written by: "+signcolour+colstring(signature));
  143.  if (privok(">"+noaliaslevel))
  144.   writeln(fhandle, reallywrittenby+"\x10a"+realnameaccess+" Who is really: "+realname+usr.name);
  145.  writeln(fhandle, seperatebarcolour+"─────────────────────────────────────────────────────────────");
  146.  
  147.  fhandle2:=open(tmpfile, IOPEN_READ);
  148.  
  149.  do {
  150.      k:=readln(fhandle2,tmpline);        // Read next line from tmpfile
  151.      if (k >= 0) writeln(fhandle,tmpline); // If not error write to newwall
  152.     }
  153.  while (k >= 0);
  154.  
  155.  close(fhandle2);    // Close tmpfile
  156.  close(fhandle);     // Close bbsfile
  157.  log(":"+usr.name+" wrote to THEWALL using the alias `"+signature+"`.");
  158.   // The above will only be written according to the log level in Maximus
  159.  end:;
  160.  }
  161.  
  162.